// 渐变流动效果模块
function initGradientEffect(canvas) {
    // 获取2D渲染上下文
    const ctx = canvas.getContext('2d');
    let time = 0;
    
    function animate() {
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        
        // 创建渐变
        const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
        
        // 使用时间使渐变颜色随时间变化
        const hue1 = 200 + Math.sin(time * 0.001) * 40;
        const hue2 = 240 + Math.cos(time * 0.001) * 40;
        
        gradient.addColorStop(0, `hsl(${hue1}, 70%, 30%)`);
        gradient.addColorStop(0.5, `hsl(${hue2}, 70%, 40%)`);
        gradient.addColorStop(1, `hsl(${hue1}, 70%, 30%)`);
        
        ctx.fillStyle = gradient;
        ctx.fillRect(0, 0, canvas.width, canvas.height);
        
        // 更新时间
        time++;
        
        requestAnimationFrame(animate);
    }
    
    animate();
}

// 暴露函数到全局作用域
window.initGradientEffect = initGradientEffect;